<%@ page import="cn.school.service.SubjectService" %>
<%@ page import="cn.school.entity.Subject" %>
<%@ page import="java.util.List" %>
<%@ page import="cn.school.service.GradeService" %>
<%@ page import="cn.school.entity.Grade" %>
<%@ page import="java.util.Map" %><%--
  Created by IntelliJ IDEA.
  User: ghost
  Date: 2019/12/9
  Time: 15:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%@include file="checkLogin.jsp"%>
<table border="1" cellpadding="10" cellspacing="0">
    <tr><td>课程名称</td><td>课时</td><td>班级</td></tr>
<%
    Object p = request.getParameter("pageNosb");
    int pageNo = 1;
    if(p != null){
        pageNo = Integer.parseInt(p.toString());
    }
    SubjectService ss = new SubjectService();
    List<Subject> list = ss.findALL(pageNo,10);
    GradeService gs = new GradeService();
    Map<String,String> map = gs.map();
    for(Subject s : list){%>
    <tr><td><%=s.getSubjectname()%></td><td><%=s.getClassHour()%></td><td><%=map.get(Long.toString(s.getGradeid()))%></td></tr>
<%
    }
%>
</table>
<%
    int total = ss.total()/10;
    if(total > 1){
        if(pageNo != 1){
            out.print("<a href='subjectinfo.jsp?pageNosb="+(pageNo-1)+"'>上一页</a>");
        }
        for (int i = 1;i<=total;i++){
            if(i == pageNo){
                out.print("\t<a>第"+i+"页</a>\t");
                continue;
            }
            out.print("\t<a href='subjectinfo.jsp?pageNosb="+i+"'>第"+i+"页</a>\t");
        }
        if(pageNo != total){
            out.print("<a href='subjectinfo.jsp?pageNosb="+(pageNo+1)+"'>下一页</a>");
        }
    }
%>
</body>
</html>
